﻿<%@ page language="java" import="weaver.general.Util" pageEncoding="UTF-8"%>
<%@ include file="/systeminfo/init_wev8.jsp" %>
<%@ taglib uri="/WEB-INF/weaver.tld" prefix="wea"%>
<%@ taglib uri="/browserTag" prefix="brow"%>
<jsp:useBean id="RecordSet" class="weaver.conn.RecordSet" scope="page" />
<jsp:useBean id="bb" class="weaver.general.BaseBean" scope="page"/>
<%
String imagefilename = "/images/hdMaintenance_wev8.gif";
String titlename = "条形码查询";
String needfav ="1";
String needhelp ="";


String sqlForm = " from workflow_requestbase a ";
String sqlWhere=" where workflowid in(751,670,766) and currentnodetype=3 ";

String djh = Util.null2String(request.getParameter("djh"));
String djhs = Util.null2String(request.getParameter("djhs"));
bb.writeLog("in---sm_list>>>djhs="+djhs.replace( "'", "" ));

if(!djhs.equals("")){
	sqlWhere += " and requestmark in ("+djhs+") ";
}else{
	sqlWhere += " and 1=2 ";
}
	String [] arr =  djhs.split( ",");
	String orderby = "order by case requestmark ";
	for(int i=0;i<arr.length;i++){
		String str = " when "+arr[i]+" then "+i;
		orderby +=str;
	}
	orderby += " else 0 end";
	String backFields = " row_number() over("+orderby+") as rownum,requestid,requestmark,requestname,(select workflowname from workflow_base where id=workflowid) workflowname,"+
			"(select nodename from workflow_nodebase where id=currentnodeid) nodename,(select lastname from hrmresource where id = creater) createrName,createdate ";
bb.writeLog("select "+backFields+sqlForm+sqlWhere+orderby);
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
<SCRIPT language="javascript" src="/js/weaver_wev8.js"></script>
<SCRIPT language="javascript" src="/js/weaverTable_wev8.js"></script>
<SCRIPT type="text/javascript" src="/formmode/js/WdatePicker/WdatePicker_wev8.js"></script>
<LINK REL=stylesheet type=text/css HREF=/css/Weaver_wev8.css>
<link href="/formmode/css/formmode_wev8.css" type="text/css" rel="stylesheet" />
<style>
*, textarea{
	font: 12px Microsoft YaHei;
}
a{

}
.e8_tblForm{
	width: 100%;
	margin: 0 0;
	border-collapse: collapse;
}
.e8_tblForm .e8_tblForm_label{
	vertical-align: top;
	border-bottom: 1px solid #e6e6e6;
	padding: 5px 2px;
}
.e8_tblForm .e8_tblForm_field{
	border-bottom: 1px solid #e6e6e6;
	padding: 5px 7px;
	background-color: #f8f8f8;
}
.e8_label_desc{
	color: #aaa;
}
#loading{
    position:absolute;
    left:45%;
    background:#ffffff;
    top:40%;
    padding:8px;
    z-index:20001;
    height:auto;
    border:1px solid #ccc;
}
</style>
  </head>

  <body>
<%@ include file="/systeminfo/TopTitle_wev8.jsp" %>
<%@ include file="/systeminfo/RightClickMenuConent_wev8.jsp" %>
<%
//RCMenu += "{确定选择,javaScript:doOK(),_self} " ;
//RCMenuHeight += RCMenuHeightStep ;
RCMenu += "{清空条件,javaScript:doClear(),_self} " ;
RCMenuHeight += RCMenuHeightStep ;

%>
<%@ include file="/systeminfo/RightClickMenu_wev8.jsp" %>
<form name="frmSearch" id="frmSearch" method="post" action="sm_list.jsp">
<table class="e8_tblForm">
<tr>
	<td class=field style="width: 15%;">流程单据号：</td>
	<td>
		<input name="djh" id ="djh" style="width: 200px;" value="<%=djh %>">
		<input name="djhs" id ="djhs" type="hidden" value="<%=djhs %>">
	</td>
</tr>
</table>
</form>
<br/>
<%
int perpage = 20;
String tableString=""+
"<table  pagesize=\""+perpage+"\" tabletype=\"checkbox\">"+
	  "<sql backfields=\""+backFields+"\" sumColumns=\"\" decimalFormat=\"\" sqlform=\""+sqlForm+"\" sqlprimarykey=\"requestid\" sqlsortway=\"desc\"  sqldistinct=\"true\" sqlwhere=\""+sqlWhere+"\" sqlorderby=\"rownum\"/>"+
	  "<head>"+
	  	 "<col width=\"20%\" text=\"请求标题\" column=\"requestname\" linkkey=\"requestid\"  linkvaluecolumn=\"requestid\" href=\"/workflow/request/ViewRequest.jsp?isovertime=0\" target=\"_fullwindow\" />"+
	  	 //"<col width=\"20%\" text=\"请求标题\" column=\"requestname\" />"+
		 "<col width=\"20%\" text=\"流程编号\" column=\"requestmark\" />"+
		 "<col width=\"20%\" text=\"流程类型\" column=\"workflowname\" />"+
		 "<col width=\"20%\" text=\"当前节点\" column=\"nodename\" />"+
		 "<col width=\"10%\" text=\"创建日期\" column=\"createdate\" />"+
		 "<col width=\"10%\" text=\"创建人\" column=\"createrName\" />"+
	  "</head>"+
"</table>";
%>

<wea:SplitPageTag  tableString='<%=tableString%>'  mode="run" isShowTopInfo="true"/>
  </body>
<script type="text/javascript">
var sheight = screen.height;
var swidth = screen.width;
var winoption = "dialogHeight:" + sheight + "px;dialogWidth:" + swidth + "px;status:yes;scroll:yes;resizable:yes;center:yes";
var oldval = "";
var newval = "";
jQuery(document).ready(function(){
	$(".loading", window.parent.document).hide(); //隐藏加载图片

	jQuery("#djh").val("");
	jQuery("#djh").focus();
	jQuery("#djh").blur(function(){
		jQuery("#djh").focus();
	});

	jQuery("#djh").keyup(function(){
		//alert(event.keyCode);
		if(event.keyCode == 13){
			//alert("value:"+$(this).val());
			OnChangePage(1);
		}
	});


	var input=jQuery("#djh").val();
    var txt="";
    var count=0;
    var timer = setInterval(function(){
		input=jQuery("#djh").val();
        if(input=="")
            return;
        if(txt!=jQuery("#djh").val()){
            txt=jQuery("#djh").val();
        }else{
            count++;
			clearInterval(timer);
			OnChangePage(1);
        }
    },100);

	//jQuery("#djh").val("");
	//jQuery("#djh").focus();
	//jQuery("#djh").bind("input",function(){
		//alert("1:"+$(this).val());
		//OnChangePage(1);
	//});

	//jQuery("#djh").blur(function(){
		//jQuery("#djh").val("");
		//jQuery("#djh").focus();
	//});

	//jQuery(document).click(function(){
		//alert(12);
	//});
});

function doClear(){
	jQuery("#djh").val("");
	jQuery("#djhs").val("");
	document.frmSearch.method = "post";
	document.frmSearch.submit();
}

function doOK(){
	var batchRequestid = "";
	jQuery("input[name='chkInTableTag']").each(function(){
		var checkboxid = $(this).attr("checkboxid");
		if($(this).attr("checked")==true){
			batchRequestid = batchRequestid+","+checkboxid;
		}
	});
	if(batchRequestid==""){
		alert("请选择数据！");
		return;
	}
	batchRequestid = batchRequestid.substring(1);
	//window.close();
	//window.parent.close();
	//alert(window.parent.dialog);
	//alert(window.parent.parent.dialog);
	return batchRequestid;
}

function OnChangePage(start){
	var requestmark = jQuery("#djh").val();
	var str = getRequestid(requestmark);
	if(str=="1"){
		alert("当前扫描付款单已被引用，不能重复引用！");
		return;
	}
	var djhs = jQuery("#djhs").val();
	if(djhs==""){
		djhs = "'"+requestmark+"'";
	}else{
		djhs += ",'"+requestmark+"'";
	}
	jQuery("#djhs").val(djhs);
	document.frmSearch.method = "post";
	document.frmSearch.submit();
}

/**查询流程
**/
function getRequestid(requestmark){
	var str = "";
	if(requestmark!=""){
		jQuery.ajax({
			type:"POST",
			async: false,
			url:"/jobs/baicheng/sm_ajax.jsp?action=checkUsed&requestmark="+requestmark,
			success:function(res){
				var json = eval("("+res+")");
				str = json.result;
			},
			error:function(e){}
		});
	}
	return str;
}

var dialog = null;
function showDialog(url){
	var diaHeight = $(document).height()*1;
	var diaWidth = $(document).width()*1;
   	dialog = new top.Dialog();
   	dialog.currentWindow = window;
   	dialog.Drag = true;
   	dialog.Width = diaWidth;
   	dialog.Height = diaHeight;
   	dialog.URL = url;
	dialog.show();
}

function onShowBrowser(inputName, spanName){
    	var datas = window.showModalDialog("/systeminfo/BrowserMain.jsp?url=/hrm/resource/ResourceBrowser.jsp");
    	if (datas){
    	    if(datas.id!=""){
    		    $("#"+inputName).val(datas.id);
    			if ($("#"+inputName).val()==datas.id){
    		    	$("#"+spanName).html(datas.name);
    			}
    	    }else{
    		    $("#"+inputName).val("");
    			$("#"+spanName).html("");
    		}
    	}
    }

function onSearchWFQTDate(spanname,inputname){
	var oncleaingFun = function(){
		  $(spanname).innerHTML = '';
		  inputname.value = '';
		}
		WdatePicker({el:spanname,onpicked:function(dp){
			var returnvalue = dp.cal.getDateStr();
			$dp.$(inputname).value = returnvalue;
		},oncleared:oncleaingFun});
}
</script>
  </body>
</html>
